import java.util.ArrayList;
import java.util.HashMap;



public class Options {
	private HashMap<String, String> options = new HashMap<String,String>(); 
	private ArrayList<String> params = new ArrayList<String>(); 
	public Options(String[] args) { 
		for(int i=0; i<args.length; i++) { 
			if (args[i].equals("-")) { 
				for(int j=i+1; j<args.length; j++) { 
				    params.add(args[j]); 
				}
				return; 
			} else if (args[i].startsWith("-")) { 
			    String name=args[i]; 
			    String value = ""; 
			    if ((i+1) < args.length && !args[i+1].startsWith("-")) { 
			        value = args[i+1]; 
			        i = i+1; 
			    } 
			    options.put(name, value); 
			}  else { 
                for(int j=i; j<args.length; j++) { 
                    params.add(args[j]); 
                }
                return; 			    
			}
		}
	}
	
	public String getOption(String name) { 
	    return options.get(name); 
	}

	public boolean hasOption(String name) { 
	    return options.containsKey(name); 
	}
	
	public String getParameter(int index) { 
	    if (index >= params.size()) { 
	        return null; 
	    }
	    return params.get(index); 
	}
	
}
